    {%- include "c_agile_slave/c_agile_slave_fun_common.jinja2" %}
    while (u8ILoop < len)
    {
        switch(address + u8ILoop)
        {
            {%- for region in slave.regions.holding_coils.regions -%}
            {%- for register in region.registers %}
            case {{register.address}}: 
                {%- if register.length > 1 %}
                for (u8JLoop = 0; u8JLoop < {{register.length}} && u8ILoop < len; u8JLoop++, u8ILoop++)
                {
                    u8Bit = ((*(((uint8_t*)inbuf) + (u8ILoop / 8))) >> (8 - u8ILoop % 8)) & 0x01;
                    ptRegster->{{register.name}} &= ~(1 << u8JLoop);
                    ptRegster->{{register.name}} |= ((*(((uint8_t*)inbuf) + (u8ILoop / 8))) >> (8 - u8ILoop % 8) & 0x01) << u8JLoop;
                }
                {%- else %}
                ptRegster->{{register.name}} = ((*(((uint8_t*)inbuf) + (u8ILoop / 8))) >> (8 - u8ILoop % 8)) & 0x01;
                u8ILoop++;
                {%- endif %}
                break;
            {%- endfor %}
            {%- endfor %}
            default:
                return -1;
        }
    }

    return 0;